import options from '@/utils/options'

/**
 * 灵活可变的字段模板
 */
export const flexibleTemplate = {
  '普通字段模板': {
    jfieldName: '',
    fieldName: '',
    fieldDesc: '',
    jfieldType: '',
    fieldType: '',
    fieldLength: 0,
    fieldScale: 0,
    primaryKey: false,
    pkStrategy: 0,
    defaultValue: '',
    notNull: false,
    foreignKey: false,
    specialField: '',
    fieldExample: '',
    fieldComment: '',
    dicType: '',
    query: false,
    queryType: null,
    insert: true,
    update: true,
    list: true,
    columnWidth: 0,
    listSort: false,
    show: true,
    editType: options.editTypeOptions['TEXT'].value,
    orderNo: 1,
    labels: []
  },
  '外键模板': {
    jfieldName: '',
    fieldName: '',
    fieldDesc: '',
    jfieldType: '',
    fieldType: '',
    fieldLength: 0,
    fieldScale: 0,
    primaryKey: false,
    pkStrategy: 0,
    defaultValue: '',
    notNull: false,
    foreignKey: true,
    specialField: '',
    fieldExample: '',
    fieldComment: '',
    dicType: '',
    query: true,
    queryType: 1,
    insert: true,
    update: true,
    list: false,
    columnWidth: 0,
    listSort: false,
    show: true,
    editType: options.editTypeOptions['SELECT'].value,
    orderNo: 10,
    labels: []
  }
}
/**
 * 固定字段模板
 */
export const fixedTemplate = {
  '主键ID(Long-自增)': {
    jfieldName: 'id',
    fieldName: 'id',
    fieldDesc: '主键',
    jfieldType: 'Long',
    fieldType: 'bigint',
    fieldLength: 20,
    fieldScale: 0,
    primaryKey: true,
    pkStrategy: 1,
    defaultValue: '',
    notNull: true,
    foreignKey: false,
    specialField: '',
    fieldExample: '1',
    fieldComment: '主键ID',
    dicType: '',
    query: false,
    queryType: null,
    insert: false,
    update: false,
    list: true,
    columnWidth: 100,
    listSort: false,
    show: true,
    editType: options.editTypeOptions['TEXT'].value,
    orderNo: 1,
    labels: []
  },
  '主键ID(Integer-自增)': {
    jfieldName: 'id',
    fieldName: 'id',
    fieldDesc: '主键',
    jfieldType: 'Integer',
    fieldType: 'int',
    fieldLength: 11,
    fieldScale: 0,
    primaryKey: true,
    pkStrategy: 1,
    defaultValue: '',
    notNull: true,
    foreignKey: false,
    specialField: '',
    fieldExample: '1',
    fieldComment: '主键ID',
    dicType: '',
    query: false,
    queryType: null,
    insert: false,
    update: false,
    list: true,
    columnWidth: 100,
    listSort: false,
    show: true,
    editType: options.editTypeOptions['TEXT'].value,
    orderNo: 1,
    labels: []
  },
  '主键ID(UUID-32)': {
    jfieldName: 'id',
    fieldName: 'id',
    fieldDesc: '主键',
    jfieldType: 'String',
    fieldType: 'varchar',
    fieldLength: 32,
    fieldScale: 0,
    primaryKey: true,
    pkStrategy: 2,
    defaultValue: '',
    notNull: true,
    foreignKey: false,
    specialField: '',
    fieldExample: '1',
    fieldComment: '主键ID',
    dicType: '',
    query: false,
    queryType: null,
    insert: false,
    update: false,
    list: true,
    columnWidth: 150,
    listSort: false,
    show: true,
    editType: options.editTypeOptions['TEXT'].value,
    orderNo: 1,
    labels: []
  },
  '主键ID(UUID-16)': {
    jfieldName: 'id',
    fieldName: 'id',
    fieldDesc: '主键',
    jfieldType: 'String',
    fieldType: 'varchar',
    fieldLength: 16,
    fieldScale: 0,
    primaryKey: true,
    pkStrategy: 3,
    defaultValue: '',
    notNull: true,
    foreignKey: false,
    specialField: '',
    fieldExample: '1',
    fieldComment: '主键ID',
    dicType: '',
    query: false,
    queryType: null,
    insert: false,
    update: false,
    list: true,
    columnWidth: 150,
    listSort: false,
    show: true,
    editType: options.editTypeOptions['TEXT'].value,
    orderNo: 1,
    labels: []
  },
  '创建时间(Date)': {
    jfieldName: 'createdTime',
    fieldName: 'created_time',
    fieldDesc: '创建时间',
    jfieldType: 'Date',
    fieldType: 'datetime',
    fieldLength: 0,
    fieldScale: 0,
    primaryKey: false,
    pkStrategy: 0,
    defaultValue: '',
    notNull: true,
    foreignKey: false,
    specialField: 'createdTime',
    fieldExample: '2017-12-07 00:00:00',
    fieldComment: '创建时间【yyyy-MM-dd HH:mm:ss】',
    dicType: '',
    query: false,
    queryType: null,
    insert: false,
    update: false,
    list: true,
    columnWidth: 200,
    listSort: true,
    show: false,
    editType: options.editTypeOptions['DATETIME'].value,
    orderNo: 100,
    labels: []
  },
  '创建时间(LocalDateTime)': {
    jfieldName: 'createdTime',
    fieldName: 'created_time',
    fieldDesc: '创建时间',
    jfieldType: 'LocalDateTime',
    fieldType: 'datetime',
    fieldLength: 0,
    fieldScale: 0,
    primaryKey: false,
    pkStrategy: 0,
    defaultValue: '',
    notNull: true,
    foreignKey: false,
    specialField: 'createdTime',
    fieldExample: '2017-12-07 00:00:00',
    fieldComment: '创建时间【yyyy-MM-dd HH:mm:ss】',
    dicType: '',
    query: false,
    queryType: null,
    insert: false,
    update: false,
    list: true,
    columnWidth: 200,
    listSort: true,
    show: false,
    editType: options.editTypeOptions['DATETIME'].value,
    orderNo: 100,
    labels: []
  },
  '创建人': {
    jfieldName: 'createdBy',
    fieldName: 'created_by',
    fieldDesc: '创建人',
    jfieldType: 'String',
    fieldType: 'varchar',
    fieldLength: 20,
    fieldScale: 0,
    primaryKey: false,
    pkStrategy: 0,
    defaultValue: '',
    notNull: true,
    foreignKey: false,
    specialField: 'createdBy',
    fieldExample: 'admin',
    fieldComment: '创建人【最大长度20】',
    dicType: '',
    query: false,
    queryType: null,
    insert: false,
    update: false,
    list: false,
    columnWidth: 0,
    listSort: false,
    show: false,
    editType: options.editTypeOptions['TEXT'].value,
    orderNo: 101,
    labels: []
  },
  '创建服务器IP': {
    jfieldName: 'createdIp',
    fieldName: 'created_ip',
    fieldDesc: '创建服务器IP',
    jfieldType: 'String',
    fieldType: 'varchar',
    fieldLength: 15,
    fieldScale: 0,
    primaryKey: false,
    pkStrategy: 0,
    defaultValue: '',
    notNull: true,
    foreignKey: false,
    specialField: 'createdIp',
    fieldExample: '127.0.0.1',
    fieldComment: '创建服务器IP【最大长度15】',
    dicType: '',
    query: false,
    queryType: null,
    insert: false,
    update: false,
    list: false,
    columnWidth: 0,
    listSort: false,
    show: false,
    editType: options.editTypeOptions['TEXT'].value,
    orderNo: 102,
    labels: []
  },
  '修改时间(Date)': {
    jfieldName: 'operatedTime',
    fieldName: 'operated_time',
    fieldDesc: '修改时间',
    jfieldType: 'Date',
    fieldType: 'datetime',
    fieldLength: 0,
    fieldScale: 0,
    primaryKey: false,
    pkStrategy: 0,
    defaultValue: '',
    notNull: true,
    foreignKey: false,
    specialField: 'operatedTime',
    fieldExample: '2017-12-07 00:00:00',
    fieldComment: '修改时间【yyyy-MM-dd HH:mm:ss】',
    dicType: '',
    query: false,
    queryType: null,
    insert: false,
    update: false,
    list: true,
    columnWidth: 200,
    listSort: true,
    show: false,
    editType: options.editTypeOptions['DATETIME'].value,
    orderNo: 110,
    labels: []
  },
  '修改时间(LocalDateTime)': {
    jfieldName: 'operatedTime',
    fieldName: 'operated_time',
    fieldDesc: '修改时间',
    jfieldType: 'LocalDateTime',
    fieldType: 'datetime',
    fieldLength: 0,
    fieldScale: 0,
    primaryKey: false,
    pkStrategy: 0,
    defaultValue: '',
    notNull: true,
    foreignKey: false,
    specialField: 'operatedTime',
    fieldExample: '2017-12-07 00:00:00',
    fieldComment: '修改时间【yyyy-MM-dd HH:mm:ss】',
    dicType: '',
    query: false,
    queryType: null,
    insert: false,
    update: false,
    list: true,
    columnWidth: 200,
    listSort: true,
    show: false,
    editType: options.editTypeOptions['DATETIME'].value,
    orderNo: 110,
    labels: []
  },
  '修改人': {
    jfieldName: 'operatedBy',
    fieldName: 'operated_by',
    fieldDesc: '修改人',
    jfieldType: 'String',
    fieldType: 'varchar',
    fieldLength: 20,
    fieldScale: 0,
    primaryKey: false,
    pkStrategy: 0,
    defaultValue: '',
    notNull: true,
    foreignKey: false,
    specialField: 'operatedBy',
    fieldExample: 'admin',
    fieldComment: '修改人【最大长度20】',
    dicType: '',
    query: false,
    queryType: null,
    insert: false,
    update: false,
    list: false,
    columnWidth: 0,
    listSort: false,
    show: false,
    editType: options.editTypeOptions['TEXT'].value,
    orderNo: 111,
    labels: []
  },
  '修改服务器IP': {
    jfieldName: 'operatedIp',
    fieldName: 'operated_ip',
    fieldDesc: '修改服务器IP',
    jfieldType: 'String',
    fieldType: 'varchar',
    fieldLength: 15,
    fieldScale: 0,
    primaryKey: false,
    pkStrategy: 0,
    defaultValue: '',
    notNull: true,
    foreignKey: false,
    specialField: 'operatedIp',
    fieldExample: '127.0.0.1',
    fieldComment: '修改服务器IP【最大长度15】',
    dicType: '',
    query: false,
    queryType: null,
    insert: false,
    update: false,
    list: false,
    columnWidth: 0,
    listSort: false,
    show: false,
    editType: options.editTypeOptions['TEXT'].value,
    orderNo: 112,
    labels: []
  },
  '乐观锁版本号': {
    jfieldName: 'version',
    fieldName: 'version',
    fieldDesc: '乐观锁版本号',
    jfieldType: 'Integer',
    fieldType: 'int',
    fieldLength: 11,
    fieldScale: 0,
    primaryKey: false,
    pkStrategy: 0,
    defaultValue: '',
    notNull: true,
    foreignKey: false,
    specialField: 'version',
    fieldExample: '1',
    fieldComment: '乐观锁版本号【整型】',
    dicType: '',
    query: false,
    queryType: null,
    insert: false,
    update: false,
    list: false,
    columnWidth: 0,
    listSort: false,
    show: false,
    editType: options.editTypeOptions['NUMBER'].value,
    orderNo: 120,
    labels: []
  },
  '逻辑删除标识': {
    jfieldName: 'deleted',
    fieldName: 'deleted',
    fieldDesc: '逻辑删除标识',
    jfieldType: 'Boolean',
    fieldType: 'tinyint',
    fieldLength: 1,
    fieldScale: 0,
    primaryKey: false,
    pkStrategy: 0,
    defaultValue: '',
    notNull: true,
    foreignKey: false,
    specialField: 'deleted',
    fieldExample: 'false',
    fieldComment: '逻辑删除标识【0-未删除，1-已删除】',
    dicType: '',
    query: false,
    queryType: null,
    insert: false,
    update: false,
    list: false,
    columnWidth: 0,
    listSort: false,
    show: false,
    editType: options.editTypeOptions['RADIO'].value,
    orderNo: 130,
    labels: []
  },
  '排序号': {
    jfieldName: 'orderNo',
    fieldName: 'order_no',
    fieldDesc: '排序号',
    jfieldType: 'Integer',
    fieldType: 'int',
    fieldLength: 11,
    fieldScale: 0,
    primaryKey: false,
    pkStrategy: 0,
    defaultValue: '',
    notNull: true,
    foreignKey: false,
    specialField: '',
    fieldExample: '1',
    fieldComment: '排序号【整型】',
    dicType: '',
    query: false,
    queryType: null,
    insert: true,
    update: true,
    list: true,
    columnWidth: 100,
    listSort: true,
    show: true,
    editType: options.editTypeOptions['NUMBER'].value,
    orderNo: 90,
    labels: []
  }
}

export const findSystemTemplate = function (key) {
  const t1 = flexibleTemplate[key]
  if (t1) {
    return t1
  } else {
    return fixedTemplate[key]
  }
}
